//
//  RegistNumberView.m
//  Project_IOS
//
//  Created by Jeff on 2022/1/18.
//

#import "RegistNumberView.h"
#import <Masonry/Masonry.h>
#import "Color.h"
@interface RegistNumberView ()

@property (nonatomic, strong) UIButton *moreBtn;
@property (nonatomic, strong) UIView *contentView;

@property (nonatomic, strong) UIView *textView;

@property (nonatomic, strong) UILabel *codeLb;

@end


@implementation RegistNumberView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    [self addSubview:self.contentView];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(311, 52));
        make.top.left.mas_equalTo(0);
    }];
    
    [self.contentView addSubview:self.textField];
    
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(16);
        make.left.mas_equalTo(82);
        make.centerY.mas_equalTo(0);
    }];
    
    [self.contentView addSubview:self.codeLb];
    
    [self.contentView addSubview:self.moreBtn];
    [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(12, 12));
            make.centerY.mas_equalTo(0);
            make.right.mas_equalTo(self.textField.mas_left).offset(-16);
    }];
    [self.moreBtn setImage:[UIImage imageNamed:@"triangle_down"] forState:UIControlStateNormal];
    
    [self.codeLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.centerY.mas_equalTo(0);
            make.right.mas_equalTo(self.moreBtn.mas_left).offset(0);
    }];
    self.codeLb.text = @"+86";
    
}

- (UIView *)contentView {
    if (!_contentView) {
        _contentView = [[UIView alloc] init];
        _contentView.backgroundColor = [Color colorWithHexString:@"#F7F7F7"];
        _contentView.layer.cornerRadius = 26;
        _contentView.layer.masksToBounds = true;
        
    }
    return _contentView;
}


- (UITextField *)textField {
    if (!_textField) {
        _textField = [[UITextField alloc] init];
        _textField.textColor = [Color colorWithHexString:@"#333333"];
        _textField.font = [UIFont systemFontOfSize:16];
        _textField.textAlignment = NSTextAlignmentLeft;
        _textField.placeholder = @"请输入手机号";
        _textField.keyboardType = UIKeyboardTypeNumberPad;
    }
    return _textField;
}

- (UIButton *)moreBtn {
    if (!_moreBtn) {
        _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_moreBtn addTarget:self action:@selector(showSecure) forControlEvents:UIControlEventTouchUpInside];
    }
    return _moreBtn;
}

- (UILabel *)codeLb {
    if (!_codeLb) {
        _codeLb = [[UILabel alloc] init];
        _codeLb.textColor = [Color colorWithHexString:@"#333333"];
        _codeLb.font = [UIFont boldSystemFontOfSize:16];
        _codeLb.textAlignment = NSTextAlignmentCenter;
    }
    return _codeLb;
}


- (void)showSecure {
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
